package org.csu.jpetstorespringversion.controller;

import org.csu.jpetstorespringversion.model.Category;
import org.csu.jpetstorespringversion.service.CategoryService;
import org.csu.jpetstorespringversion.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("main")
public class MainController {
    @Autowired
    private CategoryService categoryService;
    private ProductService productService;

    @GetMapping("index")
    public ModelAndView mainShow(Model model){
        List<Category>categoryList= categoryService.list(null);
        model.addAttribute("categoryList",categoryList);
        return new ModelAndView("catalog/Main");
    }

}
